#region Imports

using System;
using Microsoft.SharePoint;

#endregion

namespace IEC.ColumnOrdering.SP2007.Deployment
{

    /// <summary>
    /// Provides helper functionality for the web context.
    /// </summary>
    internal static class WebContextHelper
    {

        #region Methods - Static Member

        /// <summary>
        /// Gets the current web.
        /// </summary>
        /// <param name="properties">
        /// The properties from which the current web is to be extracted.
        /// </param>
        /// <returns>
        /// The current web.
        /// </returns>
        public static SPWeb GetCurrentWeb(SPFeatureReceiverProperties properties)
        {
            SPWeb currentWeb = null;

            if (properties.Feature.Parent is SPWeb)
            {
                currentWeb = properties.Feature.Parent as SPWeb;
            }
            else
            {
                SPSite site = properties.Feature.Parent as SPSite;
                currentWeb = site.OpenWeb();
            }

            return currentWeb;
        }

        #endregion

    }

}
